package com.ruoyi.erp.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.erp.domain.LedyBacFee;
import com.ruoyi.erp.service.ILedyBacFeeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 案件费用明细Controller
 * 
 * @author ztj
 * @date 2023-04-04
 */
@RestController
@RequestMapping("/erp/fee")
public class LedyBacFeeController extends BaseController
{
    @Autowired
    private ILedyBacFeeService ledyBacFeeService;

    /**
     * 查询案件费用明细列表
     */
    @PreAuthorize("@ss.hasPermi('erp:fee:list')")
    @GetMapping("/list")
    public TableDataInfo list(LedyBacFee ledyBacFee)
    {
        startPage();
        List<LedyBacFee> list = ledyBacFeeService.selectLedyBacFeeList(ledyBacFee);
        return getDataTable(list);
    }

    /**
     * 导出案件费用明细列表
     */
    @PreAuthorize("@ss.hasPermi('erp:fee:export')")
    @Log(title = "案件费用明细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, LedyBacFee ledyBacFee)
    {
        List<LedyBacFee> list = ledyBacFeeService.selectLedyBacFeeList(ledyBacFee);
        ExcelUtil<LedyBacFee> util = new ExcelUtil<LedyBacFee>(LedyBacFee.class);
        util.exportExcel(response, list, "案件费用明细数据");
    }

    /**
     * 获取案件费用明细详细信息
     */
    @PreAuthorize("@ss.hasPermi('erp:fee:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(ledyBacFeeService.selectLedyBacFeeById(id));
    }

    /**
     * 新增案件费用明细
     */
    @PreAuthorize("@ss.hasPermi('erp:fee:add')")
    @Log(title = "案件费用明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LedyBacFee ledyBacFee)
    {
        return toAjax(ledyBacFeeService.insertLedyBacFee(ledyBacFee));
    }

    /**
     * 修改案件费用明细
     */
    @PreAuthorize("@ss.hasPermi('erp:fee:edit')")
    @Log(title = "案件费用明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LedyBacFee ledyBacFee)
    {
        return toAjax(ledyBacFeeService.updateLedyBacFee(ledyBacFee));
    }

    /**
     * 删除案件费用明细
     */
    @PreAuthorize("@ss.hasPermi('erp:fee:remove')")
    @Log(title = "案件费用明细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ledyBacFeeService.deleteLedyBacFeeByIds(ids));
    }
}
